<template>
  <div class="mod-api__jobregist">
    <el-form :inline="true" :model="state.dataForm" @keyup.enter="state.getDataList()">
      <el-form-item>
        <el-input v-model.trim="state.dataForm.realName" placeholder="真实姓名" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-select v-model="state.dataForm.companyId" placeholder="请选择公司" value-key="" clearable filterable @change="">
          <el-option key="" label="全部" value=""> </el-option>
          <el-option v-for="item in vcxvfgt" :key="item.id" :label="item.name" :value="item.id"> </el-option>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-select v-model="state.dataForm.status" placeholder="请选择审核状态" value-key="" clearable filterable @change="">
          <el-option key="" label="全部" value=""> </el-option>
          <!-- <el-option  key="0" label="未审核" value="0"> </el-option> -->
          <el-option key="1" label="待审核" value="1"> </el-option>
          <el-option key="2" label="审核通过" value="2"> </el-option>
          <el-option key="3" label="审核不通过" value="3"> </el-option>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="state.getDataList()">搜索</el-button>
      </el-form-item>
      <el-form-item>
        <el-button v-if="state.hasPermission('api:jobregist:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
      </el-form-item>
      <el-form-item>
        <el-button type="danger" @click="state.deleteHandle()">删除</el-button>
      </el-form-item>
      <el-form-item>
        <el-button type="info" @click="state.exportHandle()">导出</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="state.dataListLoading" :data="state.dataList" border @selection-change="state.dataListSelectionChangeHandle" style="width: 100%">
      <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
      <!-- <el-table-column prop="id" label="id" header-align="center" align="center"></el-table-column>
              <el-table-column prop="userId" label="注册用户id" header-align="center" align="center"></el-table-column> -->
      <el-table-column prop="realName" label="姓名" header-align="center" align="center"></el-table-column>
      <el-table-column label="性别" width="60" header-align="center" align="center">
        <template #default="scope">
          <span v-if="scope.row.gender == 0 || scope.row.gender == null">男</span>
          <span v-if="scope.row.gender == 1">女</span>
        </template>
      </el-table-column>
      <el-table-column prop="userMobile" label="联系方式" header-align="center" align="center"></el-table-column>
      <!-- <el-table-column prop="jobId" label="工作id" header-align="center" align="center"></el-table-column> -->
      <el-table-column prop="companyId" label="公司名称" header-align="center" align="center">
        <template #default="scope">
          {{ jkxdfxsd(scope.row.companyId) }}
        </template>
      </el-table-column>
      <el-table-column prop="jobName" label="工作标题" header-align="center" align="center"></el-table-column>
      <el-table-column prop="inviteRealName" label="邀请人" header-align="center" align="center"></el-table-column>
      <el-table-column prop="status" label="状态 " header-align="center" align="center">
        <template #default="scope">
          {{ kmxzcf(scope.row.status) }}
        </template>
      </el-table-column>
      <el-table-column prop="createTime" label="报名时间" header-align="center" align="center"></el-table-column>
      <el-table-column label="操作" fixed="right" header-align="center" align="center" width="150">
        <template v-slot="scope">
          <el-button type="primary" link @click="addOrUpdateHandle(scope.row.id)" v-if="scope.row.status != 2">审核</el-button>
          <el-button type="primary" link @click="state.deleteHandle(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination :current-page="state.page" :page-sizes="[10, 20, 50, 100]" :page-size="state.limit" :total="state.total" layout="total, sizes, prev, pager, next, jumper" @size-change="state.pageSizeChangeHandle" @current-change="state.pageCurrentChangeHandle"> </el-pagination>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update ref="addOrUpdateRef" @refreshDataList="state.getDataList">确定</add-or-update>
  </div>
</template>

<script lang="ts" setup>
import useView from "@/hooks/useView";
import { reactive, ref, toRefs } from "vue";
import AddOrUpdate from "./jobregist-add-or-update.vue";
import { kmxzcf } from "@/utils/utils";
import { dxget, zkjsd, transferTimeYMD } from "@/utils/utils";
const vcxvfgt = ref([]);
const view = reactive({
  deleteIsBatch: true,
  getDataListURL: "/sys/jobregist/page",
  getDataListIsPage: true,
  exportURL: "/api/jobregist/export",
  deleteURL: "/api/jobregist"
});

const state = reactive({ ...useView(view), ...toRefs(view) });

const addOrUpdateRef = ref();
const addOrUpdateHandle = (id?: number) => {
  addOrUpdateRef.value.init(id);
};
const injxsd = async () => {
  const resd = await dxget("/sys/tmcompany/option");
  vcxvfgt.value = resd;
};
injxsd();

const jkxdfxsd = (item) => {
  try {
    return vcxvfgt.value.filter((a) => a.id == item)[0].name;
  } catch (e) {
    return "-";
  }
};
</script>
